package cn.tedu.lbs.marketing.web.controller;

import cn.tedu.lbs.marketing.web.service.ActivityService;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.pojo.marketing.param.ActivityParam;
import com.tarena.lbs.pojo.marketing.query.ActivityQuery;
import com.tarena.lbs.pojo.marketing.vo.ActivityVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 专门负责 和活动也有 http接口
 */
@RestController
public class ActivityController {
    @Autowired
    private ActivityService activityService;
    //活动分页列表查询
    @PostMapping("/admin/marketing/marketingActivity/info/list")
    public Result<PageResult<ActivityVO>> pageList(@RequestBody ActivityQuery query)
        throws BusinessException{
        return new Result<>(activityService.pageList(query));
    }
    //活动表单提交
    @PostMapping("/admin/marketing/marketingActivity/info/save")
    public Result<Void> save(@RequestBody ActivityParam param)
        throws BusinessException{
        activityService.save(param);
        return Result.success();
    }
    //小程序用户 查看活动详情
    @GetMapping("/admin/marketing/marketingActivity/info/detail/{id}")
    public Result<ActivityVO> detail(@PathVariable Integer id)
        throws BusinessException{
        return new Result<>(activityService.detail(id));
    }
}
